<%@ page language="java" import="java.util.*, java.text.*,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.userinfo.manager.*, com.zjut.zs.userinfo.dao.*,
com.zjut.zs.cj.manager.*, com.zjut.zs.cj.dao.*,com.zjut.zs.xy.manager.*, com.zjut.zs.xy.dao.*,
com.zjut.zs.exvalue.manager.*, com.zjut.zs.exvalue.dao.*,com.zjut.zs.coname.manager.*, com.zjut.an.config.manager.*, com.zjut.an.config.dao.*,
com.zjut.zs.zxlb.manager.*, com.zjut.zs.zxlb.dao.*,com.zjut.zs.file.manager.*, com.zjut.zs.file.dao.*,
com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,
com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*,com.zjut.zs.applyview.dao.*,com.zjut.zs.applyview.manager.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src='../plugins/assets/plugins/jquery-3.5.1.min.js'></script>
</head>

<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsApplyViewManager amanager = (ZsApplyViewManager) SpringContextUtil.getBean("ZsApplyViewManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsZxlbManager xmanager = (ZsZxlbManager) SpringContextUtil.getBean("ZsZxlbManager");
ZsUserStatusManager smanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");

ZsExValue exv = new ZsExValue();
ZsUser user = null;
if(session.getAttribute("admin")!=null && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");	
} 

ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);

String message = amanager.checkSend(user);


ZsZxlb zxlb = new ZsZxlb();
List zxlist = new ArrayList();
if (user!=null) {
	zxlb.setZsUser(user);
	zxlist = xmanager.getDataByInstance(1,100,null,null,zxlb).getObjects();
}
StringBuffer zxstring = new StringBuffer();
for(int i=0; i<zxlist.size(); i++) {
	zxlb = (ZsZxlb)zxlist.get(i);
	zxstring.append(zxlb.getZxType()+"|"+zxlb.getZxName()+"|"+zxlb.getZxJb()+";");
}
String key = MD5.toMD5(user.getUsId().toString());
 %>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="#">提交申请表</a></li>
    </ul>
    </div>
    <div class="formbody">
    <div class="formtitle"><span>提交申请表</span></div>
    <%if(Status.ON.getStatus().equals(school.getScAppActive())){ //如果仍然可以提交%>
    <form id="ff" name="add" role="form" class="form-horizontal" action="javascript:send();"  method="post">	    
		<%if(message.length()>0){ 
			out.print("<div class='info'>"+message+"</div>");
		}else {
			ZsUserStatus userStatus = smanager.getDataByUser(user);
			if(Status.SENDSTATUS_NULL.getStatus().equals(userStatus.getSendStatus())||Status.SENDSTATUS_NO.getStatus().equals(userStatus.getSendStatus())){ %>					
				<div id="show"></div>
				<button type="submit" id="button" class="btn btn-primary btn-sm"  style="display:none;">提交</button>		
		 	<%}else {%>	
		 		<button type="submit" id="button" class="btndisable" disabled><%=userStatus.getSendStatus() %></button>
		 	<%}%>
		<%}%>	
		
    </form>
    <%} else {%>
   申请表提交已经关闭。
    <%} %>
    
    </div>
   
<div style="margin:50px;"><%out.print(anconfig.getSingleConfigInfoByName("申请提交填写需知")); %></div>
<script src="../admin/js/publicManager.js" type="text/javascript" charset="utf-8"></script> 
<script type="text/javascript">
var updateOneAction = '../zsExValueSave.action?randnum='+Math.floor(Math.random()*1000000);
var loactionurl = 'zs_send.jsp';
</script>
<script type="text/javascript">
var json;
var zxlb="<%=zxstring%>";
$(function(){
	$.get("../zsApplyView.action?usId=<%=user.getUsId()%>&randnum="+Math.floor(Math.random()*1000000), function(data) {
		json=data.rows;
		<%=school.getScCheckJs() %>
	});
});

function send() {
	if(confirm("提交后，申请表信息将不能再修改。是否确认提交？")) {
		$.ajax({
	    	cache: false,
	    	type: "GET",
	        url:'../zsUserStatusSendPublic.action?usId=<%=user.getUsId()%>&key=<%=key%>&randnum='+Math.floor(Math.random()*1000000),
	        data:{},// 你的formid
	        async: false,
	        error: function(request) {
	        	alert("提交有误");
	        },
	        success: function(data) {
	        	if (data.flag == "success") {
	        		alert("提交成功，请继续提交材料");
		            console.log(data);
		            if ("undefined" != typeof loactionurl) {
		            	top.window.location = 'main.jsp';
		            }
	        	} else {
	        		alert("提交有误，请确认申请表信息是否完整后再次尝试");	
	        	}
	        }
	    });
	}
}

	
</script> 
<%} %>
</body>

</html>
